//算数运算符
let aab = 1;
let bba = 1 + aab;
console.log(bba);
console.log(100 - 50);
console.log(10 * 3);
console.log(10 / 2);
console.log(10 / 3);
console.log(9 ** 0.5);
console.log(10 ** 2);  //次方(幂)
console.log(11 % 3);   //取余
console.log(b = 100);  //赋值


//43天等于多少星期多少天
let quannian = 365;
let day = quannian % 7; //取余
let xingqi = parseInt(quannian / 7);  //这个才是真的计算
console.log(xingqi, day);

// //4725秒等于多少时分秒
let miao4725 = 4725;
let shi = parseInt(miao4725 / 3600);
let fen = parseInt((miao4725 - (shi * 3600)) / 60);
let miao = miao4725 - (shi * 3600 + fen * 60);
console.log(shi, fen, miao);


//自增和自减
let aa1, bb1, cc1;
aa1 = bb1 = cc1 = 100;
console.log(aa1, bb1, cc1);
aa1 += 100; //a = a + 100;
console.log(aa1);
let aaa1 = 10;
aaa1 ??= 100;  //空赋值 如果变量aaa1为null或者undefined的时候 就赋值为100 否则就不赋值
console.log(aaa1);


let a_ = 100;
a_++;  //a = a + 1;
++a_;  //a = a + 1;
a_--;    //a = a - 1;
--a_;    //a = a - 1;
console.log(a_);

let a2 = 100;
let b2 = ++a2;
console.log(b2);
console.log(a2);


let x = 4;
let y = (--x) + (x--) + (x * 10);
// let y = A + B + C
//       3/3 +  2/3 + 2 * 10
//   3 + 3 + 2 * 10
// x = 2, y = 26
console.log(x, y);

let a3 = 6;
let b3 = 10;
let c3 = a3++ + b3 + ++a3 + b3++ + ++b3 + a3;
//      7/6 + 10 + 8/8 + 11/10 + 12/12 + 8
// 6 + 10 + 8 + 10 + 12 + 8 = 54
console.log(c3);


let a4 = 1;
let b4 = a4++ + ++a4 + a4 * 10 + a4++;
//       2/1   3/3 + 3/30 + 4/3
//       1 + 3 + 30 + 3 = 37
console.log(b4);


let a5 = 1;
let b5 = a5++ + (++a5 + a5) * 10 + a5++;
//      2/1     3/3  3   4/3
//   1 + (3 + 3) * 10 + 3  = 64
console.log(b5);

// 关系运算符
console.log(100 > 10);
console.log(-100 < 10);
console.log(-100 >= 10);
console.log(5 < 5);
console.log(5 <= 5);
console.log(5 == 5);
console.log(5 === 5);
console.log(null == undefined);
console.log(null === undefined);
let a6 = 100;
console.log(a6 == 200);
console.log(a6);
console.log(NaN != NaN);

let age = 100;
let retval = 10 < age < 50;
// 10 < age
// age < 50
console.log(retval);  //true


let age2 = 100;
let retval2 = age2 > 10 && age2 < 50;
// 10 < age2
// age2 < 50
console.log(retval2);  //false

let a1 = 1;
(a1 == 1) && (a1 = 3);
console.log(a1);

let b1 = 1;
let c1 = (b1 == 1) && (b1 = 3) && (b1 = 6);
console.log(c1);
console.log(b1);

let bb2 = 1;
let cc2 = false;
if (bb2 == 1) {
    if (bb2 = 3) {
        cc2 = bb2 = 6
    }
}
console.log(cc2);
console.log(bb2);


let age3 = 0;
let retval3 = age3 > 10 || age3 < 50;
// 10 < age
// age < 50
console.log(retval3);


let aa3 = 1;
aa3 || (aa3 = 100);
console.log(aa3);

let bb3;
bb3 = bb3 || 100;
console.log(bb3);

let bb4 = 10;
if (!bb4) {
    bb4 = 100;
}
console.log(bb4);

let bb5 = 10;
console.log(!!bb5);


let bb6 = 2, cc6 = 1;
let d6 = 100;
let aa6 = bb6 == cc6 ? 3 + d6 : 6 * d6;
console.log(a6);


let a7 = 1100, b7 = 200, c7 = 300;
let retval7 = a7 > b7 ? a7 : b7;
retval7 = retval7 > c7 ? retval7 : c7;
console.log(retval7);


//100 + (200 * 3);
let b8 = 2, c8 = 1;
b8 == c8 ? (console.log(100), console.log(200)) : console.log(300);


//隐式类型转换
console.log(+new Date());  //当+-作为一元运算符时，代表强制转换到数字，如果无法转换，返回NaN。这里的+new Date()的输出是时间戳
let d1 = "100";
d1 = +d1;  //将d1转换为数字，如果无法转换，返回NaN
console.log(d1);
console.log(100n);
console.log(55 + null);  //55
console.log(100 + true);  //101 true相当于是1
console.log(100 - "55");  //45
console.log(100 - undefined);  //NaN
console.log(100 + "55");  //10055 当+作为二元运算符时，如果有一个操作数是字符串，则另一个操作数也会被转换为字符串，然后把两个字符串拼接
console.log(100 > "155");  //当对非数值进行关系运算时，会将其转换为数值，然后进行比较。这里"100"转换为100，"155"转换为155，所以比较结果为false
console.log("a" < "b"); //当关系运算符两边都是字符串时，会比较字符串的Unicode编码，所以结果为true
console.log("1" < "2");
console.log("abcd" < "adcd");
console.log("小" < "大");





